package com.newegg.datafeed.adserving.mapper;

import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import com.newegg.datafeed.adserving.domain.Adserving;

@Mapper
public interface AdservingMapper {

	@Select("SELECT id,operateid,company,company_name,channel,channel_name,user,usernickname,delivery_time,complete_time,complete,memo FROM adserving")
    @Results({
    	@Result(property = "companyName",  column = "company_name"),
    	@Result(property = "channelName",  column = "channel_name"),
    	@Result(property = "deliveryTime",  column = "delivery_time"),
    	@Result(property = "completeTime",  column = "complete_time")
    })
	List<Adserving> getAll();
	
	@Insert("INSERT INTO adserving(id,operateid,company,company_name,channel,channel_name,user,usernickname,delivery_time,complete_time,complete,memo) VALUES (#{id},#{operateid},#{company},#{companyName},#{channel},#{channelName},#{user},#{usernickname},#{deliveryTime},#{completeTime},#{complete},#{memo});")
    void insert(Adserving adserving);
	
	@Update("UPDATE adserving SET operateid=#{operateid},company=#{company},company_name=#{companyName},channel=#{channel},channel_name=#{channelName},user=#{user},usernickname=#{usernickname},delivery_time=#{deliveryTime},complete_time=#{completeTime},complete=#{complete},memo=#{memo} WHERE id =#{id}")
    void update(Adserving adserving);
	
	@Delete("DELETE FROM adserving WHERE id=#{id}")
    void delete(int id);
}
